package sf.dynamicsql.mapper;

import org.mybatis.dynamic.sql.select.SelectModel;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import sf.common.wrapper.Page;
import sf.core.DBObject;
import sf.database.dao.DBContext;
import sf.dynamicsql.DynamicSqlTable;

import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Stream;

public interface DynmicSQLMapper<T extends DBObject> {
    /**
     * @return
     */
    DynamicSqlTable dynmicSQLTable();

    /**
     * @param context
     * @return
     */
    DynamicSqlTable dynmicSQLTable(DBContext context);

    /**
     * @param provider
     * @return
     */
    List<T> selectList(SelectStatementProvider provider);

    /**
     * @param provider
     * @param start
     * @param limit
     * @return
     */
    Page<T> selectPage(SelectStatementProvider provider, int start, int limit);

    /**
     * @param provider
     * @param clz
     * @param <S>
     * @return
     */
    <S> S selectOne(SelectStatementProvider provider, Class<S> clz);

    /**
     * @param provider
     * @return
     */
    T selectOne(SelectStatementProvider provider);

    /**
     * @param ormIt
     * @param provider
     */
    void selectIterator(Consumer<Iterable<T>> ormIt, SelectStatementProvider provider);

    /**
     * @param ormStream
     * @param provider
     */
    void selectStream(Consumer<Stream<T>> ormStream, SelectStatementProvider provider);

    /**
     * @param selectModel
     * @return
     */
    List<T> selectList(SelectModel selectModel);

    /**
     * @param selectModel
     * @param start
     * @param limit
     * @return
     */
    Page<T> selectPage(SelectModel selectModel, int start, int limit);

    /**
     * @param selectModel
     * @param clz
     * @param <S>
     * @return
     */
    <S> S selectOne(SelectModel selectModel, Class<S> clz);

    /**
     * @param selectModel
     * @return
     */
    T selectOne(SelectModel selectModel);

    /**
     * @param ormIt
     * @param selectModel
     */
    void selectIterator(Consumer<Iterable<T>> ormIt, SelectModel selectModel);

    /**
     * @param ormStream
     * @param selectModel
     */
    void selectStream(Consumer<Stream<T>> ormStream, SelectModel selectModel);
}
